<template>
  <div id="app">
    <mt-header fixed title="黑马">
      <span slot="left" @click="Return" v-show="flag">
        <mt-button icon="back">返回</mt-button>
      </span>
    </mt-header>

      <transition>
          <router-view></router-view>
      </transition>

    <nav class="mui-bar mui-bar-tab">
        <router-link  to="/home">
          <span class="mui-icon mui-icon-home"></span>
          <span class="mui-tab-label">首页</span>
        </router-link>
        <router-link  to="/Member">
          <span class="mui-icon mui-icon-email"></span>
          <span class="mui-tab-label">会员</span>
        </router-link>
        <router-link  to="/Shopcar">
          <span class="mui-icon mui-icon-contact">
            <span class="mui-badge" id="badge">{{$store.getters.getAllCount}}</span></span>
          <span class="mui-tab-label">购物车</span>
        </router-link>
        <router-link  to="/search">
          <span class="mui-icon mui-icon-gear"></span>
          <span class="mui-tab-label">搜索</span>
        </router-link>
		</nav>

  </div>
</template>

<script>
export default {
  name: "App",
  data(){
    return{
      flag:false
    }
  },
  methods:{
    Return(){
      this.$router.go(-1)
    }
  },
  created() {
    this.Return(); 
    this.flag = this.$route.path === '/home' ? false : true
  },
  watch:{
    '$route.path':function(newVal){
      if(newVal === "/home"){
        this.flag = false
      }else{
        this.flag = true
      }
    }
  }
};
</script>

<style>
mt-header{
  z-index: 99;
  /* position: relative; */
}
*{
  margin: 0;
  padding: 0;
}
.Return{
    position: fixed;
    top: 10px;
    left: 20px;
    z-index: 999;
    color: #fff;
}
#app {
  padding-top: 40px;
  padding-bottom: 50px;
  overflow-x: hidden;
}
.v-enten{
  opacity: 0;
  transform: translateX(100%);
  /* position: absolute; */
}
.v-leave-to{
  opacity: 0;
  transform: translateX(-100%);
  position: absolute;
}
.mint-tabbar{
  position: fixed;
}
.v-enten-active,
.v-leave-active{
  transition: all 0.5s ease;
}
</style>
